home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Report Writers / Crystal Repot 9.0 Full CD version / Setup.exe / Tools / Developers / PEDELF32.ZIP / pedelf32 / LOCATION.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-09-30  |  2.4 KB  |  86 lines

  1. unit Location;
  2.  
  3. interface
  4.  
  5. uses             
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, Buttons;
  8.  
  9. type
  10.   TFrmLocation = class(TForm)
  11.     LstDisplay: TListBox;
  12.     BtnOK: TBitBtn;
  13.     procedure FormShow(Sender: TObject);
  14.     procedure BtnOKClick(Sender: TObject);
  15.   private
  16.     { Private declarations }
  17.   public
  18.     { Public declarations }
  19.     function  GetError(Const JobIn : Integer) : String;
  20.   end;
  21.  
  22. var
  23.   FrmLocation: TFrmLocation;
  24.  
  25. implementation
  26. uses
  27.    Main, CRDelphi;
  28.  
  29. {$R *.DFM}
  30.  
  31. function TFrmLocation.GetError(Const JobIn : Integer) : String;
  32. {This is my print engine error message capture function. It accepts
  33.  the job number as it parameter and then gets the error code and
  34.  message text and then passes this back out as a formatted string}
  35. var
  36.   Code : Integer;
  37.   StrHandle : hWnd;
  38.   Buffer : PChar;
  39.   Length : SmallInt;
  40.   Ret : Bool;
  41.  
  42. begin
  43.    Code := PEGetErrorCode(JobIn); {Get the Error code from the Crpe}
  44.    Ret := PEGetErrorText(JobIn, StrHandle, Length);  {Get the error message handle}
  45.  
  46.    Buffer := StrAlloc(Length);
  47.    {get the text from the text handle}
  48.    Ret := PEGetHandleString(StrHandle, Buffer, Length);
  49.  
  50.    GetError := IntToStr(Code) + ' - ' + StrPas(Buffer); {output the string}
  51.    StrDispose(Buffer);
  52. end;
  53.  
  54. procedure TFrmLocation.FormShow(Sender: TObject);
  55. var
  56.   Iterator, Tables : Integer;
  57.   TableLocation : PETableLocation;
  58.  
  59. begin
  60.    {Initialize the Table location structure size}
  61.    TableLocation.StructSize := PE_SIZEOF_TABLE_LOCATION;
  62.    Tables := PEGetNTables(JobNumber);  {Get the number of tables in the report}
  63.    If Tables > 0 then   {successful return}
  64.       begin
  65.          For Iterator := 0 to Tables - 1 do  {for each table}
  66.             begin
  67.                {Get the tables location}
  68.                if PEGetNthTableLocation(JobNumber, Iterator, TableLocation) then
  69.                   {add the location to the list box}
  70.                   LstDisplay.Items.Add(StrPas(TableLocation.Location))
  71.                else
  72.                   ShowMessage(GetError(JobNumber)); {show any error messages}
  73.             end
  74.       end
  75.    else   {failed return}
  76.       ShowMessage(GetError(JobNumber)); {show any error messages}
  77.  
  78. end;
  79.  
  80. procedure TFrmLocation.BtnOKClick(Sender: TObject);
  81. begin
  82.     LstDisplay.Items.Clear   {clear the list box}
  83. end;
  84.  
  85. end.
  86.